package StringBufferExercise;

public class StringConcatenation {
    public static void main(String[] args)
    {
        String[] array = {"Hello","World","Java","Programming"};

        String resultUsingString = "";
        for(String s : array)
        {
            resultUsingString += s;
        }
        StringBuilder stringBuffer = new StringBuilder();
        for (String s : array) {
            stringBuffer.append(s);
        }
        String resultUsingStringBuffer = stringBuffer.toString();

        System.out.println("使用String拼接的结果：" + resultUsingString);
        System.out.println("使用StringBuffer拼接的结果：" + resultUsingStringBuffer);
    }
}
